﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/adminmain.master" AutoEventWireup="true" CodeFile="ListAllAdmin.aspx.cs" Inherits="admin_ListAllAdmin" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="../js/jquery-1.4.2.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("#ctl00$ContentPlaceHolder1$gvUser$ctl02$txtUName").blur(function () {
            var username = $(this).val();
            var uid = "<%=user.UId %>";
            $.post("IsExistOrNot2.ashx", { "name": username,"uid":uid }, function (data) {
                if (data == "yes") {
                    $("#isornot").html('<font color="red">用户已存在！</font>');
                } else {
                    $("#isornot").html("");
                };
            });
        });
    });
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <asp:GridView ID="gvUser" runat="server" AutoGenerateColumns="False" 
        CellPadding="4" DataSourceID="ObdsAdmins" ForeColor="#333333" 
        GridLines="None" AllowPaging="True" Width="98%">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:TemplateField HeaderText="Id" SortExpression="UId" Visible="False">
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("UId") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:Label ID="lbUId" runat="server" Text='<%# Bind("UId") %>'></asp:Label>
                </EditItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="用户名" SortExpression="UName">
                <EditItemTemplate>
                    <asp:TextBox ID="txtUName" runat="server" Text='<%# Bind("UName") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ControlToValidate="txtUName" ForeColor="#CC0000"></asp:RequiredFieldValidator>
                    <span id="isornot"></span>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("UName") %>'></asp:Label>
                </ItemTemplate>
                <ControlStyle Width="100px" />
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="密码" SortExpression="Pwd">
                <EditItemTemplate>
                    <asp:TextBox ID="txtPwd" runat="server" Text='<%# Bind("Pwd") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                  ErrorMessage="密码不能为空" ControlToValidate="txtPwd" ForeColor="Red" 
                  Display="Dynamic"></asp:RequiredFieldValidator>
              <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" 
                  ControlToValidate="txtPwd" ErrorMessage="密码格式不对" ForeColor="Red" 
                  ValidationExpression="^[\@A-Za-z0-9\!\#\$\%\^\&amp;\*\.\~]{6,32}$" 
                  Display="Dynamic"></asp:RegularExpressionValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lbPwd" runat="server" Text='<%# Bind("Pwd") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="身份" SortExpression="UserRoleId">
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlUserIdentity" runat="server" AutoPostBack="True" 
                        SelectedValue='<%# Eval("UserRole.UrId") %>' DataSourceID="ObUserRole" 
                        DataTextField="UrName" DataValueField="UrId">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="ObUserRole" runat="server" SelectMethod="getModel" 
                        TypeName="BLL.UserRoles"></asp:ObjectDataSource>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("UserRole.UrName") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="状态" SortExpression="UserStateId">
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlUserState" runat="server" DataSourceID="ObUserState" 
                        DataTextField="UsName" DataValueField="UsId" 
                        SelectedValue='<%# Eval("UserState.UsId") %>'>
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="ObUserState" runat="server" SelectMethod="getModel" 
                        TypeName="BLL.UserStates"></asp:ObjectDataSource>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("UserState.UsName") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:TemplateField>
            <asp:CommandField ShowEditButton="True" HeaderText="操作" >
            <HeaderStyle HorizontalAlign="Center" />
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:CommandField>
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
    </asp:GridView>
    <br />
    <asp:ObjectDataSource ID="ObdsAdmins" runat="server" 
        SelectMethod="getAdminModel" TypeName="BLL.Users" 
        onupdating="ObdsAdmins_Updating" DataObjectTypeName="MODEL.Users" 
        UpdateMethod="Update"></asp:ObjectDataSource>
</asp:Content>



